﻿using System;
using System.Collections.Generic;
using System.Data;
using ContractManager.Entity;
using Speed.Data;

namespace ContractManager.BLL.Business
{
    public static class ClsContractDetailDocuments
    {
        public static List<ContractDetails> SelectAll()
        {
            using (var db = Sys.NewDb())
            {
                return Data.Base.ContractDetails.Select(db);
            }
            
        }

        public static void Insert(ContractDetailDocuments capital)
        {
            using (var db = Sys.NewDb())
            {
                db.Insert<ContractDetailDocuments>(capital);
            }
            
        }

        public static void Update(ContractDetailDocuments capital)
        {
            using (var db = Sys.NewDb())
            {
                db.Update<ContractDetailDocuments>(capital);
            }
            
        }


        public static DataTable ListDetail(Int32 conId, Int32 conDetId)
        {
            using (var db = Sys.NewDb())
            {
                string commandText = String.Format("EXEC dbo.usp_ContractDetailDocuments_SelectByMaster {0},{1}", conId, conDetId);
                return db.ExecuteDataTable(commandText);
            }

        }


        public static int DeleteByPk(Int32 conDetDocId)
        {
            using (var db = Sys.NewDb())
            {
                return db.Delete<ContractDetailDocuments>(string.Format("ConDetDocId={0}", conDetDocId));
            }
            
        }
    }
}